// TODO：请补充代码
function startGame() {
  let score = 0;
  document.querySelector("#start").style.display = "none";
  const scoreSpan = document.querySelector('#score');
  const imgAll = document.querySelectorAll("img");
  imgAll.forEach((item) => {
    item.style.display = "block";
  });
  setTimeout(() => {
    imgAll.forEach((item) => {
      item.style.display = "none";
    });
  }, 1000);
  const imgBox = document.querySelectorAll(".img-box");
  let a = null;
  let b = null;
  for (let i = 0; i < imgBox.length; i++) {
    imgBox[i].addEventListener("click", (e) => {
      e.target.children[0].style.display = "block";
      // console.log(e.target.children[0]);
      setTimeout(() => {
        if (a == null) {
          // a = e.target.children[0].alt;
          a = e.target.children[0];
          console.log(a);
        } else if (b == null) {
          b = e.target.children[0];
          console.log(b);
          if (a.alt === b.alt) {
            a.parentNode.style.visibility = "hidden";
            b.parentNode.style.visibility = "hidden";
            score += 2;
          } else {
            a.style.display = "none";
            b.style.display = "none";
            score -= 2;
          }
          scoreSpan.innerHTML = score;
          a = null;
          b = null;
        }
      }, 500);
    });
  }
}
